//需要充值的页面
// let vipList = ['/pages/distribution/distribution']
//需要登录的页面
let list =['/pages/tabBar/myUser/myProfile','/pages/coupon/coupon','/pages/prediction/prediction','/pages/attention/attention','/pages/forecastOrders/forecastOrders',
,'/pages/recharge/recharge'
]
const install = (Vue, vm) => {
	uni.addInterceptor('navigateTo', {
		invoke(args) {
			let index = args.url.indexOf('?')==-1? args.url.length:args.url.indexOf('?')
			let activeUrl = args.url.slice(0,index);
			let userInfo = vm.$store.getters.userInfo
			let userToken = vm.$store.getters.userToken
			//检测需要登录的页面
			if(list.includes(activeUrl)&&!userInfo&&!userToken){
				console.log(args.url);
				uni.navigateTo({
					url: `/pages/login/login?from=${args.url}`,
					success: res => {
						// setTimeout(()=>{
						// 	uni.showToast({
						// 		title: '请先授权登录',
						// 		icon:'none'
						// 	});
						// },1000)
					},
					fail: () => {},
					complete: () => {}
				});
				return false; 
			}
			
		},
		success(args,params) {
			// console.log('success',params);
		},
		fail(err) {
			// console.log('interceptor-fail', err)
		},
		complete(res) {
			// console.log('interceptor-complete', res)
		}
	})
}
export default {
	install
}